package com.zb_study.Homework02;

import java.util.ArrayList;
import java.util.Iterator;

@SuppressWarnings({"all"})
public class homework02 {
    public static void main(String[] args) {
        ArrayList arrayList = new ArrayList();
        arrayList.add(new Car("宝马",400000));
        arrayList.add(new Car("宾利",5000000));
        arrayList.remove(1);
//        for (Object o :arrayList) {
//            System.out.println(o);
//        }


        Iterator iterator = arrayList.iterator();
        while (iterator.hasNext()) {
            Car next =  (Car) iterator.next();
            System.out.println(next);
        }


    }
}


class Car {
    private String name;
    private int price;

    public Car(String name, int price) {
        this.name = name;
        this.price = price;
    }

    @Override
    public String toString() {
        return "Car{" +
                "name='" + name + '\'' +
                ", price=" + price +
                '}';
    }
}
